package com.zhuandaonet.common.exception;

import com.zhuandaonet.common.constant.Code;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

/**
 * 自定义的全局异常
 */
@Getter
@Setter
public class ServiceException extends RuntimeException{
    private static final long serialVersionUID = 4420294547643018469L;

    private Integer status = Code.Status.INTERNAL_SERVER_ERROR;

    private String errorCode = Code.Error.UNKNOWN;

    private String message = "未知的内部错误！";


    public static ServiceException builder(){
        return new ServiceException();
    }

    public ServiceException status(Integer status){
        this.status = status;
        return this;
    }

    public ServiceException errorCode(String errorCode){
        this.errorCode = errorCode;
        return this;
    }

    public ServiceException message(String message){
        this.message = message;
        return this;
    }

    public ServiceException build(){
        return this;
    }
}
